<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <button id="btn">生成彩票</button>
  <div id="result">

  </div>

  <script>
    let btn = document.getElementById('btn');
    let result = document.getElementById('result');
    let obj = {};
    
    btn.addEventListener('click', function() {
      let arr = [];
      // 生成7个 [1-36] 随机数字
      for(let i = 0; i < 7; i++){
        let num = Math.floor(Math.random() * 36) + 1;
        arr.push(num);
      }
      result.innerHTML = arr;

      let hash = Math.random();  
      location.hash = hash;

      obj[hash] = arr;

    }, false);


    window.onhashchange = function(){
      let hash = location.hash.substr(1);
      result.innerHTML = obj[hash];
    }
  </script>
</body>
</html>